package dao;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import entities.CasaCentral;

/**
 * Session Bean implementation class CasaCentralDAOBEAN
 */
@Stateless
public class CasaCentralDAOBEAN implements CasaCentralDAO {

	@PersistenceContext(name="proveedorPersistence")
    private EntityManager em;
	
    public CasaCentralDAOBEAN() {
        // TODO Auto-generated constructor stub
    }

	@SuppressWarnings("unchecked")
	@Override
	public CasaCentral obtenerCasaCentral() {
		CasaCentral casaCentral = new CasaCentral();
		Query query = em.createQuery("SELECT casacentral FROM CasaCentral casacentral");
		List<CasaCentral> listaCasaCentral = query.getResultList();
		if(!listaCasaCentral.isEmpty()){
			casaCentral = listaCasaCentral.get(0);
		}
		return casaCentral;
		
	}

}
